package com.testfileupload.uploadimg.design.flyweight;

import java.util.HashMap;

//报考信息工厂
public class SignInfoFactory {
    //池容器
    private static HashMap<String, SignInfo> pool = new HashMap<>();

    @Deprecated
    public static SignInfo getSignInfo() {
        return new SignInfo();
    }
    //从池中获取对象
    public static SignInfo getSignInfo(String key){
        //返回值
        SignInfo signInfo = null;
        if (!pool.containsKey(key)){
            System.out.println("建立对象并放到对象池"+key);
            signInfo = new SignInfo4Pool(key);
            pool.put(key,signInfo);
        }else {
            signInfo = pool.get(key);
            System.out.println("直接从池中获取"+key);
        }
        return signInfo;
    }
}
